import matplotlib.pyplot as plt
from keras.models import Model

LAYER_2_NEURONS = 7
model_to_draw2D =
    Model(inputs=model.input,outputs=model.layers[LAYER_2_NEURONS].output)
intermediate_output = model_to_draw2D.predict(X_test)
print(intermediate_output.shape)
print(y_test.shape)

plt.figure(figsize=(10,10))
for i in range(10):
    plt.scatter(intermediate_output[y_test==i,0],
           intermediate_output[y_test==i,1], marker='o', label= format(i))

plt.xlabel('Neuron 1', fontsize=15)
plt.ylabel('Neuron 2', fontsize=15)
plt.legend(prop={'size':14}); plt.grid(); 
plt.grid(True)
plt.show()
